﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Net.Sockets;

namespace SocketClient
{
    /// <summary>
    /// Interaction logic for nomejogador.xaml
    /// </summary>
    public partial class nomejogador : Window
    {
        private NetworkStream networkStream;
        private StreamReader reader;
        private StreamReader readerRetorno;
        private StreamWriter writer;

        public nomejogador(StreamReader readerRetorno, StreamReader reader, StreamWriter writer)
        {
            this.readerRetorno = readerRetorno;
            this.reader = reader;
            this.writer = writer;
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            String txt = textBox1.Text;
            try
            {
                writer.WriteLine("nomejogador    " + txt); //envia msg ao servidor
                txt = reader.ReadLine();
                menu m = new menu(readerRetorno, reader, writer);
                Close();
                m.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message);
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
